<?php

/**
 * 微商城模板配置logic
 */

namespace Wechat\Logic;

class MallTemlatesLogic extends CommonLogic {
	
	/**
	 * 获取模板详细
	 * @param  integer $id 文档ID
	 * @return array       当前模型详细信息
	 */
	public function detail($id){
		$data = $this->field(true)->find($id);
		if(!$data){
			$this->error = '获取详细信息出错！';
			return false;
		}
		
		$data['configs'] = serializeMysql($data['configs'],1);
		$data['leftconfigs'] = stripslashes($data['leftconfigs']);
		$data['rightconfigs'] = stripslashes($data['rightconfigs']);
// 		dump($data);exit;
		return $data;
	}
    
	//获取全部的模板信息
	public function allLists($map = array('vipid'=>VIPUID),$field = array('id','bg','name')){
	    $data = $this->where($map)->field($field)->order('listorder DESC')->select();
	    
	    if(in_array('configs', $field)){
	        foreach ($data as &$v){
	            $v['configs'] = serializeMysql($v['configs'],1);
	        }
	    }
	    
	    return $data;
	    
	}
	
}